#pragma  once
#include "..\IDataSet.h"
#include <vector>

#include "..\..\Content\ThreadManager.h"
#include "..\..\BoardAbstractionLayer\DABoardManeger.h"
#include "..\RealTimeDataSet\RealTimeDataSet.h"

namespace DataManager
{
	class  PADataSetUnion:public IDataSetUnion
	{
	public:
		PADataSetUnion(): index_(-1)		
		{
			using  Content::ThreadManager;
			
			data_set_ = new RealTimeDataSet;

			MessageLoopForIO * io_loop = 
				static_cast<MessageLoopForIO*>(ThreadManager::GetInstance()->GetThreadMessageLoop(ThreadManager::IO_THREAD));
			// 		test_.SetUp( io_loop, data_set_.get() );
			// 		test_.BeginCollectData( data_set_.get() );
			DA::IChannel*  channel = BMgrInstance()->GetChannelByIdx(0);
			if(channel)
				channel->SetChannelDataObserver(data_set_ );
			data_set_list_.push_back( data_set_  );
		}

		virtual bool   HasNextDataSet()			{	return index_+1 < static_cast<int>(data_set_list_.size());	}
		virtual IDataSet*	GetNextDataSet()	{	return data_set_list_[++index_];			}
		virtual void   Reset()					{	index_ = -1;			}
		virtual  DataType GetDataType()			{	return  REALTIME_DATA_TYPE;	}
	private:
		std::vector<IDataSet*>	data_set_list_;
		int						index_;
		//	RealTimeDataSetTest		test_;
		scoped_refptr<RealTimeDataSet>	data_set_;
	};
}